/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import com.opensymphony.xwork2.validator.annotations.EmailValidator;
import com.opensymphony.xwork2.validator.annotations.RegexFieldValidator;
import com.opensymphony.xwork2.validator.annotations.RequiredStringValidator;
import com.opensymphony.xwork2.validator.annotations.StringLengthFieldValidator;
import com.opensymphony.xwork2.validator.annotations.Validations;
import java.io.Serializable;
import java.util.List;

/**
 *
 * @author Thai Ha Cong
 */

public class Supplier implements Serializable {
    private Integer idSupplier;
    private String name;
    private String address;
    private String description;
    private String email;
    private String phone;
    private String others;
    private List<Receipt> receiptList;

    public Supplier() {
    }

    public Supplier(Integer idSupplier) {
        this.idSupplier = idSupplier;
    }

    public Supplier(Integer idSupplier, String name, String address, String description, String email, String phone) {
        this.idSupplier = idSupplier;
        this.name = name;
        this.address = address;
        this.description = description;
        this.email = email;
        this.phone = phone;
    }
     public Supplier( String name, String address, String description, String email, String phone) {
        this.name = name;
        this.address = address;
        this.description = description;
        this.email = email;
        this.phone = phone;
    }
    public Integer getIdSupplier() {
        return idSupplier;
    }

    public void setIdSupplier(Integer idSupplier) {
        this.idSupplier = idSupplier;
    }

    public String getName() {
        return name;
    }

      @Validations(
            requiredStrings = {
        @RequiredStringValidator(message = "Name is required.")},
            stringLengthFields = {
        @StringLengthFieldValidator(message = "Name should contains 2-30 characters.", minLength = "2", maxLength = "30")})
    public void setName(String name) {
        this.name = name;
    }

    public String getAddress() {
        return address;
    }

    @RequiredStringValidator(message = "Address is required.")
    public void setAddress(String address) {
        this.address = address;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getEmail() {
        return email;
    }

    @Validations(
            requiredStrings = {
        @RequiredStringValidator(message = "E-mail is required.")},
            emails = {
        @EmailValidator(message = "Invalid E-mail")})
    public void setEmail(String email) {
        this.email = email;
    }

    public String getPhone() {
        return phone;
    }

    @RequiredStringValidator(message = "Phone Number is required.")
    @RegexFieldValidator(message = "Invalid Phone Number.", expression = "^0\\d{9,10}$")
    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getOthers() {
        return others;
    }

    public void setOthers(String others) {
        this.others = others;
    }

    public List<Receipt> getReceiptList() {
        return receiptList;
    }

    public void setReceiptList(List<Receipt> receiptList) {
        this.receiptList = receiptList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idSupplier != null ? idSupplier.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Supplier)) {
            return false;
        }
        Supplier other = (Supplier) object;
        if ((this.idSupplier == null && other.idSupplier != null) || (this.idSupplier != null && !this.idSupplier.equals(other.idSupplier))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.Supplier[ idSupplier=" + idSupplier + " ]";
    }
    
}
